<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <input type="text" id="ele">
    <script>
        const ele = document.getElementById('ele');

        const xyInput = new Proxy(ele,{
            set(target,prop,value) { // target 为对应的对象，
                if (prop === 'value') {
                    target.dispatchEvent(new CustomEvent('change'));
                }
                // target[prop] = value;
                // return true;
                Reflect.set(target,prop,value); // Reflect.set 会返回一个 boolean 值
            },
            get(target,peop) {
                // return target[prop];
                return Reflect.get(target,prop);
            }
            
        })

        // 

        ele.addEventListener('change',() => {
            document.body.appendChild(document.createTextNode('变化了'))
        })
        xyInput.value = 'miaomaio';

    </script>
</body>
</html>